package com.enation.app.javashop.core.client.fallback.distribution;

import com.enation.app.javashop.core.client.feignimpl.distribution.DistributionOrderClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.distribution.dos.DistributionOrderDO;
import com.enation.app.javashop.model.trade.order.dos.OrderDO;
import org.springframework.stereotype.Component;

/**
 * 分销订单相关熔断factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:09
 **/
@Component
public class DistributionOrderClientFallbackFactory extends BaseFallbackFactory<DistributionOrderClientFeignImpl> {
    @Override
    protected DistributionOrderClientFeignImpl fallback() {
        return new DistributionOrderClientFallback();
    }

    /**
     * 分销订单相关熔断
     *
     * @author zh
     * @version v7.0
     * @date 18/9/27 上午10:26
     * @since v7.0
     */
    @Component
    public static class DistributionOrderClientFallback implements DistributionOrderClientFeignImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public DistributionOrderDO getModelByOrderSn(String orderSn) {
            logger.error("获取分销订单错误，订单号为" + orderSn);
            return null;
        }

        @Override
        public DistributionOrderDO add(DistributionOrderDO distributionOrderDO) {
            logger.error("新增分销订单错误，订单号为" + distributionOrderDO.getOrderSn());
            return null;
        }

        @Override
        public boolean calCommission(String orderSn) {
            logger.error("通过订单号计算各个级别返利金额错误，订单号为" + orderSn);
            return false;
        }

        @Override
        public void addOrderNum(Long buyMemberId) {
            logger.error("根据购买人增加上级人员订单数量,购买人ID为" + buyMemberId);
        }

        @Override
        public boolean calReturnCommission(String orderSn, double price) {
            logger.error("计算退款时需要退的返利金额错误,订单金额为" + orderSn);
            return false;
        }

        @Override
        public void confirm(OrderDO order) {
            logger.error("分销结算订单错误,订单号为" + order.getSn());
        }
    }
}
